import Vue from 'vue'
import Router from 'vue-router'
import Index from "../components/Index"
import Types from "../components/visitor/Types";
import Archives from "../components/visitor/Archives";
import About from "../components/visitor/AboutMe";
import Tags from "../components/visitor/Tags";
import Blog from "../components/visitor/Blog";
import Search from "../components/visitor/Search";

Vue.use(Router)

//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  routes: [
    {
      path: '/',
      redirect:'/index',
      meta: {
        title: '首页'
      }
    },
    {
      path: '/index',
      name: 'index',
      component:Index,
      meta: {
        title: '首页'
      }
    },
    {
      path: '/types',
      name: 'types',
      component:Types,
      meta: {
        title: '分类'
      }
    },
    {
      path: '/archives',
      name: 'archives',
      component:Archives,
      meta: {
        title: '归档'
      }
    },
    {
      path: '/tags',
      name: 'tags',
      component:Tags,
      meta: {
        title: '标签'
      }
    },
    {
      path: '/aboutMe',
      name: 'aboutMe',
      component:About,
      meta: {
        title: '关于我'
      }
    },
    {
      path: '/blog',
      name: 'blog',
      component:Blog,
      meta: {
        title: '博客详情'
      }
    },
    {
      path: '/search',
      name: 'search',
      component:Search,
      meta: {
        title: '搜索结果'
      }
    }
  ]
})
